package com.threefivework.mymall.model.util;

import com.google.common.collect.Maps;
import com.threefivework.mymall.wechat.request.UnifiedOrderRequest;
import com.threefivework.mymall.wechat.response.UnifiedOrderResponse;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * descripiton:
 *
 * @author: kinson(2219945910@qq.com)
 * @date: 2018/6/29
 * @time: 0:07
 * @modifier:
 * @since:
 */
public class UnifiedOrderBeanUtil {

    public static Map<String, String> unifiedOrderRequest2SignMap(final UnifiedOrderRequest unifiedOrderRequest) {
        Assert.notNull(unifiedOrderRequest, "nifiedOrderRequest不能为空");
        Map<String, String> reqSignData = Maps.newHashMap();
        reqSignData.put("appid", unifiedOrderRequest.getAppId());
        reqSignData.put("mch_id", unifiedOrderRequest.getMchId());
        reqSignData.put("nonce_str", unifiedOrderRequest.getNonceStr());
        return reqSignData;
    }

    public static Map<String, String> unifiedOrderResponse2SignMap(final UnifiedOrderResponse unifiedOrderResponse) {
        Assert.notNull(unifiedOrderResponse, "unifiedOrderResponse不能为空");
        Map<String, String> respSignData = Maps.newHashMap();
        respSignData.put("appid", unifiedOrderResponse.getAppId());
        respSignData.put("mch_id", unifiedOrderResponse.getMchId());
        respSignData.put("nonce_str", unifiedOrderResponse.getNonceStr());
        return respSignData;
    }
}
